#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>

static GtkWidget *entry;

int num_count = 0;


void PressPlus(GtkButton *button,gpointer data)
{
    num_count++;
    char ch[30];
    sprintf(ch, "%d", num_count);
    gtk_label_set_label (GTK_LABEL(data), ch);
}

void PressMin(GtkButton *button,gpointer data)
{
    num_count--;
    char ch[30];
    sprintf(ch, "%d", num_count);
    gtk_label_set_label (GTK_LABEL(data), ch);
}

/*-------------------------------------------------------------------------------------*/
//主函数:main()
int main(int argc,char* argv[])
{
    /*创建指向GtkWidget类型的指针*/
    GtkWidget *window;
    GtkWidget *plus;
    GtkWidget *min;
    GtkWidget *label;
    GtkBuilder *builder = NULL;
    /*初始化*/
    gtk_init(&argc,&argv);

    builder=gtk_builder_new();
    gtk_builder_add_from_file(builder,"glade.glade",NULL);
    gtk_builder_connect_signals(builder, NULL);

    // 根据 ID 获取子构件 
    window=GTK_WIDGET(gtk_builder_get_object(builder,"window")); 
    plus=GTK_WIDGET(gtk_builder_get_object(builder,"plus")); 
    min=GTK_WIDGET(gtk_builder_get_object(builder,"min")); 
    label=GTK_WIDGET(gtk_builder_get_object(builder,"label")); 

    g_object_unref(G_OBJECT(builder)); 
    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}